const jwt = require("jsonwebtoken");
const pool = require("../pool.js");
const { errLog } = require("../utils/err"); //日志记录
const FlakeIdGen = require("flake-idgen"),
    intformat = require("biguint-format"),
    generator = new FlakeIdGen();
const AdmZip = require("adm-zip");
const AppInfoParser = require("app-info-parser");
const bplistParser = require("bplist-parser");
const plist = require("plist");
const { Client } = require("ssh2");
const conn = new Client();
const poolmomo = require("../poolmomo.js");
const poolmuseo = require("../poolmuseo.js");

const androidPublisherConn = require("../google/googleapis"); // './publisher' 是该文件的路径
// 引入uuid模块
const { v4: uuidv4 } = require("uuid");
module.exports = {
    setToken({ uid }) {
        let token = jwt.sign({ uid }, "user");
        return token;
    },
    verToken(token) {
        try {
            let res = jwt.verify(token, "user");
            return res;
        } catch (err) {
            return false;
        }
    },
    createId() {
        const id = generator.next();
        const snowflake = intformat(id, "dec");
        return snowflake;
    },
    query(sql, params) {
        return new Promise((resolve, reject) => {
            pool.query(sql, params, (error, results, fields) => {
                if (error) {
                    return reject(error);
                }
                resolve(results);
            });
        });
    },
    queryMOMO(sql, params) {
        return new Promise((resolve, reject) => {
            poolmomo.query(sql, params, (error, results, fields) => {
                if (error) {
                    return reject(error);
                }
                resolve(results);
            });
        });
    },
    createInsertSql(tableName, dataObject) {
        const keys = Object.keys(dataObject);
        const values = Object.values(dataObject);

        const columnNames = keys.join(", ");
        const valuePlaceholders = keys.map((key, index) => `?`).join(", ");

        // 对于MySQL，我们不使用 RETURNING * 子句
        const text = `INSERT INTO ${tableName}(${columnNames}) VALUES(${valuePlaceholders})`;

        return {
            text,
            values,
        };
    },
    formatDate(date) {
        const year = date.getFullYear();
        const month = (date.getMonth() + 1).toString().padStart(2, "0");
        const day = date.getDate().toString().padStart(2, "0");
        const hours = date.getHours().toString().padStart(2, "0");
        const minutes = date.getMinutes().toString().padStart(2, "0");
        const seconds = date.getSeconds().toString().padStart(2, "0");

        return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
    },
    formatDate1(date) {
        const year = date.getFullYear();
        const month = (date.getMonth() + 1).toString().padStart(2, "0");
        const day = date.getDate().toString().padStart(2, "0");
        const hours = date.getHours().toString().padStart(2, "0");
        const minutes = date.getMinutes().toString().padStart(2, "0");
        const seconds = date.getSeconds().toString().padStart(2, "0");

        return `${year}-${month}-${day}`;
    },
    convertToDollars(amount) {
        // 尝试将字符串转换为数字
        const number = parseFloat(amount);

        // 检查转换后的值是否为有效的数字且不为零
        if (!isNaN(number) && number !== 0) {
            return number / 1000;
        } else {
            return amount; // 保留原值
        }
    },
    /**
     * 判断名称是否重复
     * @param string sql sql语句
     * @param string name sql查询参数name
     * @param string msg 提示语
     * @param object req 请求主体
     * @param object res 响应主体
     * */
    existName({ sql, name, msg = "名称已存在！", req, res }) {
        return new Promise((resolve, reject) => {
            if (!name) return resolve(true);
            pool.query(sql, [name], (err, result) => {
                if (err) return res.send(this.returnData({ code: -1, msg, err, req }));
                if (result.length > 0)
                    return res.send(this.returnData({ code: -1, msg, err, req }));
                resolve(true);
            });
        });
    },
    /**
     * 判断修改的名称是否和修改前的一样
     * @param string sql sql语句
     * @param string sqlName 修改前的属性名
     * @param string name 修改后的值
     * @param number id sql条件参数
     * */
    judgeUserName({ sql, sqlName = "name", name, id }) {
        return new Promise((resolve, reject) => {
            // let sql = "SELECT name FROM user WHERE  id=?";
            pool.query(sql, [id], (err, result) => {
                if (err) return resolve(1);
                if (result[0][sqlName] == name) return resolve(-1);
                return resolve(1);
            });
        });
    },
    /**
     * 响应总函数
     * @param number code 状态码
     * @param string msg 提示文字
     * @param number total 查询总数量
     * @param object data 数据
     * @param object err 错误信息
     * @param object req 错误信息
     * @param object funName 错误信息记录名称
     * */
    returnData({
        code = 1,
        msg,
        total = 0,
        data = {},
        err,
        req = {},
        funName,
    } = {}) {
        if (code == 1 && !msg) msg = "请求成功！";
        if (code == -1 && !msg) msg = "服务器异常！";
        if (code == 203 && !msg) msg = "登陆失效，请重新登陆！";
        let res = { code, msg, data };
        if (total !== 0) res.total = total;
        if (err) res.err = err;
        //记录错误日志
        if (code != 1) errLog({ err, code, msg, req, funName });
        return res;
    },
    /**
     * 获取用户信息
     * @param object req 请求主体
     * @param object res 响应主体
     * */
    getUserInfo(req, res) {
        return new Promise((resolve) => {
            let token = req.headers.token;
            if (!token) return res.send(this.returnData({ code: 203, req }));
            let user = this.verToken(token);
            if (!user) return res.send(this.returnData({ code: 203, req }));
            let sql =
                "SELECT id,name,status,roles_id AS rolesId,admin,more_id AS moreId FROM user WHERE id=?";
            pool.query(sql, [user.uid], (err, result) => {
                if (err)
                    return res.send(
                        this.returnData({
                            code: -1,
                            msg: "服务端用户信息获取错误！",
                            err,
                            req,
                        })
                    );
                if (result.length === 0)
                    return res.send(
                        this.returnData({ code: -1, msg: "用户不存在！", err, req })
                    );
                resolve(result[0]);
            });
        });
    },
    /**
     * 分页页码处理
     * @param number page 页码
     * @param number size 最大数量
     * */
    pageSize(page, size) {
        if (!page) {
            page = 1;
        }
        if (!size) {
            size = 10;
        }
        page = (page - 1) * size;
        size = parseInt(size);
        return { page, size };
    },
    /**
     * 查询总数
     * @param string name 表名
     * @param string where 查询条件
     * @param object res 主体
     * */
    getSum({ name, where, res, req }) {
        return new Promise((resolve, reject) => {
            let sql = `SELECT count(1) FROM ${name} ${where}`;
            pool.query(sql, (err, result) => {
                if (err)
                    return res.send(
                        this.returnData({ code: -1, msg: "获取数据总数错误！", err, req })
                    );
                resolve({ total: result[0]["count(1)"] });
            });
        });
    },
    /**
     * 查询列表总数
     * @param string name 表名
     * @param string where 查询条件
     * @param object res 主体
     * */
    getListSum(sql, params, res, req) {
        return new Promise((resolve, reject) => {
            pool.query(sql, params, (err, result) => {
                if (err)
                    return res.send(
                        this.returnData({ code: -1, msg: "获取数据总数错误！", err, req })
                    );
                resolve({ total: result[0].total_count });
            });
        });
    },
    getListSumMuseo(sql, params, res, req) {
        return new Promise((resolve, reject) => {
            poolmuseo.query(sql, params, (err, result) => {
                if (err)
                    return res.send(
                        this.returnData({ code: -1, msg: "获取数据总数错误！", err, req })
                    );
                resolve({ total: result[0].total_count });
            });
        });
    },
    getListSumMOMO(sql, params, res, req) {
        return new Promise((resolve, reject) => {
            poolmomo.query(sql, params, (err, result) => {
                if (err)
                    return res.send(
                        this.returnData({ code: -1, msg: "获取数据总数错误！", err, req })
                    );
                resolve({ total: result[0].total_count });
            });
        });
    },
    getListSumMOMO(sql, params, res, req) {
        return new Promise((resolve, reject) => {
            poolmomo.query(sql, params, (err, result) => {
                if (err)
                    return res.send(
                        this.returnData({ code: -1, msg: "获取数据总数错误！", err, req })
                    );
                resolve({ total: result[0].total_count });
            });
        });
    },
    /**
     * 获取用户权限
     * @param object req 请求主体
     * @param object res 响应主体
     * */
    getUserRole(req, res) {
        return new Promise(async (resolve, reject) => {
            let user = await this.getUserInfo(req, res);
            let userSql = "SELECT roles,role_key FROM roles WHERE FIND_IN_SET(id,?)";
            pool.query(userSql, [user.rolesId], (err, result) => {
                if (err || result.length == 0)
                    return res.send(
                        this.returnData({ code: -1, msg: "获取权限失败！", err, req })
                    );
                let roles = result.map((t) => t.roles);
                //权限字符
                let roleKey = result.map((t) => t.role_key);
                //角色权限
                let roleAdmin = roleKey.some((t) => t === "admin");
                let hasManage = roleKey.some((t) => t === "manage");
                resolve({
                    userRole: roles.join(","),
                    roleKey,
                    user,
                    roleAdmin,
                    hasManage,
                });
            });
        });
    },
    /**
     * 菜单字符权限拦截
     * @param object req 主体
     * @param object res 主体
     * @param array role 接口权限字符数组
     * @param boolean admin 是否管理员也要遵守（默认否）
     * */
    checkPermi({ req, res, role = [], admin = false }) {
        return new Promise(async (resolve, reject) => {
            let userRole = await this.getUserRole(req, res);
            if ((userRole.roleAdmin || userRole.user.admin === 1) && !admin)
                return resolve(true);
            let sql =
                "SELECT role_key AS roleKey FROM router_menu WHERE FIND_IN_SET(id,?)";
            pool.query(sql, [userRole.userRole], (err, result) => {
                try {
                    if (err)
                        return res.send(
                            this.returnData({ code: -1, msg: "菜单权限判断错误！", err, req })
                        );
                    let roleKeyArr = result.map((t) => t.roleKey).filter((t) => t);
                    const hasPermission = role.some((permission) => {
                        return roleKeyArr.includes(permission);
                    });
                    if (hasPermission) return resolve(hasPermission);
                    res.send(
                        this.returnData({
                            code: -1,
                            msg: "暂无对应菜单请求权限！",
                            err,
                            req,
                        })
                    );
                } catch (e) {
                    res.send(
                        this.returnData({
                            code: -1,
                            msg: "菜单权限判断错误！！",
                            err: e,
                            req,
                        })
                    );
                }
            });
        });
    },
    /**
     * 角色权限拦截
     * @param object req 主体
     * @param object res 主体
     * @param array role 角色权限数组
     * @param boolean admin 是否管理员也要遵守（默认否）
     * */
    async checkRole({ req, res, role = [], admin = false }) {
        try {
            let userRole = await this.getUserRole(req, res);
            if ((userRole.roleAdmin || userRole.user.admin === 1) && !admin)
                return true;
            let roleKeyArr = userRole.roleKey;
            const hasPermission = role.some((permission) => {
                return roleKeyArr.includes(permission);
            });
            if (hasPermission) return true;
            res.send(
                this.returnData({ code: -1, msg: "暂无对应角色请求权限！", req })
            );
            return Promise.reject(false);
        } catch (e) {
            res.send(
                this.returnData({ code: -1, msg: "角色权限判断错误！", err: e, req })
            );
            return Promise.reject(false);
        }
    },
    /**
     * 是否操作的是用户总管理员
     * @param object req 请求主体
     * @param object res 响应主体
     * @param number id 查询条件id
     * */
    upAdmin({ req, res, id }) {
        return new Promise((resolve, reject) => {
            let sql = "SELECT admin FROM user WHERE id=?";
            pool.query(sql, [id], (err, result) => {
                if (err || result.length === 0)
                    return res.send(
                        this.returnData({ code: -1, msg: "管理信息判断错误！", err, req })
                    );
                if (result[0].admin === 1)
                    return res.send(
                        this.returnData({
                            code: -1,
                            msg: "无法对《总管理》执行此操作！",
                            err,
                            req,
                        })
                    );
                resolve(result);
            });
        });
    },
    /**
     * 是否操作的是角色总管理员
     * @param object req 请求主体
     * @param object res 响应主体
     * @param number id 查询条件id
     * */
    upAdminRole({ req, res, id }) {
        return new Promise((resolve, reject) => {
            let sql = "SELECT role_key FROM roles WHERE id=?";
            pool.query(sql, [id], (err, result) => {
                if (err || result.length === 0)
                    return res.send(
                        this.returnData({ code: -1, msg: "管理信息判断错误！！", err, req })
                    );
                if (result[0].role_key === "admin")
                    return res.send(
                        this.returnData({
                            code: -1,
                            msg: "无法对《角色总管理》执行此操作！",
                            err,
                            req,
                        })
                    );
                resolve(result);
            });
        });
    },
    /**
     * 通过id获取用户信息
     * @param object req 请求主体
     * @param object res 响应主体
     * @param number id 查询条件id
     * */
    getUserId({ req, res, id }) {
        return new Promise((resolve, reject) => {
            let sql = "SELECT admin FROM user WHERE id=?";
            pool.query(sql, [id], (err, result) => {
                if (err || result.length === 0)
                    return res.send(
                        this.returnData({ code: -1, msg: "用户信息错误！！", err, req })
                    );
                resolve(result[0]);
            });
        });
    },
    /**
     * 给app添加短名称
     * */
    mapPackageNamesToShortNames(results) {
        return results.map((item) => {
            switch (item.package_name) {
                case "com.ai.chat.bot.aichat":
                    item.shortName = "chat1";
                    break;
                case "com.ai.chat.bot.aichat.lite":
                    item.shortName = "chat2";
                    break;
                case "ai.chat.bot.gpt.mobile.android":
                    item.shortName = "chat5";
                    break;
                case "wamr.recover.backup.undelete.chats.messages":
                    item.shortName = "wa";
                    break;
                case "com.tree.whatsweb":
                    item.shortName = "wa2";
                    break;
                case "whatsapp.whatsweb.whatscan.dualchat.clone.scanner":
                    item.shortName = "wa3";
                    break;
                case "pdf.viewer.editor.office.document.reader":
                    item.shortName = "pdf";
                    break;
                case "applock.calculator.lock.hide.photo.private.vault":
                    item.shortName = "calculator";
                    break;
                case "stepcounter.pedometer.steptracker.calorieburner.stepz":
                    item.shortName = "stepcounter";
                    break;
                case "instasave.reels.video.story.ig.instagram.download":
                    item.shortName = "ins1";
                    break;
                case "ins.freevideodownload.pro":
                    item.shortName = "ins2";
                    break;
                case "video.downloader.insta.videodownloader.ig":
                    item.shortName = "ins3";
                    break;
                case "download.video.downloader.videodownloader.mp4":
                    item.shortName = "all";
                    break;
                case "download.video.downloader.videodownloader.instagram":
                    item.shortName = "all2";
                    break;
                case "com.zhijian.LGTVRemoteTest":
                    item.shortName = "IOSTVREMOTETEST";
                    break;
                case "com.ZhiJian.LGTVRemote":
                    item.shortName = "IOSTVREMOTE";
                    break;
                case "com.seamobitech.roku":
                    item.shortName = "roku";
                    break;
                case "com.davinci.roku":
                    item.shortName = "rokuTest";
                    break;

                case "samsung.remote.control.samsungtv":
                    item.shortName = "androidSamsung";
                    break;
                case "tv.roku.remote.control.tvremote":
                    item.shortName = "androidRoku";
                    break;
                case "tv.remote.control.lg.tvremote":
                    item.shortName = "androidLG";
                    break;
                case "tv.remote.firetv.firestick":
                    item.shortName = "androidFiretv";
                    break;

                case "tv.remote.firetv.firestick":
                    item.shortName = "androidFiretv";
                    break;
                case "com.zhijian.LGTVRemoteTest.224":
                    item.shortName = "universalControlTest";
                    break;
                case "com.seamobitech.UniversalTVRemoteControl":
                    item.shortName = "universalControl";
                    break;
                case "com.seamobitech.whatsscanwebclone":
                    item.shortName = "iosWa";
                    break;
                case "com.tcpluginunit.testApp":
                    item.shortName = "iosWaTest";
                    break;
                case "qrcode.QRCodeReader.www":
                    item.shortName = "iosQRtest";
                    break;
                case "com.seamobitech.QRCodeReadAndGenerate":
                    item.shortName = "iosQR";
                    break;
                case "qrcode.QRCodeMaker":
                    item.shortName = "iosQR2test";
                    break;
                case "com.seamobitech.QRCodeCreateAndRead":
                    item.shortName = "iosQR2";
                    break;
                case "scan.qr.code.barcode.scanner":
                    item.shortName = "android-qr";
                    break;
                case "roku.remote.control.tv.remotecontrol":
                    item.shortName = "android-roku2";
                    break;
                case "roku.remote.control.tv.remoteforroku":
                    item.shortName = "android-roku3";
                    break;
                case "food.calorie.tracker.counter.cal.ai":
                    item.shortName = "android-Calorie";
                    break;
                case "food.calorie.tracker.counter.cal.ai.debug":
                    item.shortName = "android-Calorie-test";
                    break;
                case "print.smart.printer.pdf.docs.scanner":
                    item.shortName = "android-Print";
                    break;
                case "print.smart.printer.pdf.docs.scanner.debug":
                    item.shortName = "android-Print-test";
                    break;
                case "com.tcdemotc.testApp":
                    item.shortName = "BeautyAI-test";
                    break;
                case "com.seamobitech.BeautyAI":
                    item.shortName = "BeautyAI";
                    break;
                case "com.zhijian.LGTVRemoteTest.HeartPulse":
                    item.shortName = "iosHeartPulse-test";
                    break;
                case "com.seamobitech.HeartPulse":
                    item.shortName = "iosHeartPulse";
                    break;
                case "com.zhijian.AINoteTaker":
                    item.shortName = "AINote-test";
                    break;
                case "com.finger.AINoteTaker":
                    item.shortName = "AINote";
                    break;
                case "com.tcrecipeai.testApp":
                    item.shortName = "RecipeAI-test";
                    break;
                case "com.finger.AIRecipes":
                    item.shortName = "RecipeAI";
                    break;
                case "com.TranslationAISubTitle":
                    item.shortName = "iosTransir-test";
                    break;
                case "com.trans.translationAiAndSubtitle":
                    item.shortName = "iosTransir";
                    break;
                case "com.finger.withYou":
                    item.shortName = "iosWithYou";
                    break;
                case "com.withYou.TestApp":
                    item.shortName = "iosWithYou-test";
                    break;
                case "com.zhijian.TV-Remote-Control":
                    item.shortName = "universalRemote2-test";
                    break;
                case "com.zhijian.remoteControl":
                    item.shortName = "universalRemote2";
                    break;
                case "food.scanner.calorie.counter.cal.ai":
                    item.shortName = "Calorie";
                    break;
                case "food.calorie.tracker.counter.cal.ai.debug":
                    item.shortName = "Calorie-test";
                    break;
                case "print.smart.printer.pdf.docs.scanner":
                    item.shortName = "Print";
                    break;
                case "print.smart.printer.pdf.docs.scanner.debug":
                    item.shortName = "Print-test";
                    break;
                default:
                    item.shortName = item.package_name; // 或者你可以选择不设置shortName或其他默认值
            }
            return item;
        });
    },
    // 取包名的后缀名
    getSubstringAfterLastDot(input) {



        // 检查输入是否为字符串
        if (typeof input !== "string") {
            return "";
        }

        // 查找最后一个点"."在字符串中的位置
        var lastDotIndex = input.lastIndexOf(".");

        // 如果字符串中有".", 则返回最后一个点之后的所有字符，否则返回空字符串
        if (lastDotIndex !== -1) {
            return input.substring(lastDotIndex + 1);
        } else {
            return "";
        }
    },
    //提取ipa文件的内容
    appIpaInfo(file) {
        const zip = new AdmZip(file);
        let plistData = null;

        zip.getEntries().forEach((entry) => {
            // 使用正则表达式对象来匹配Info.plist文件
            const regex = /Payload\/[^\/]+\.app\/Info\.plist/;
            if (regex.test(entry.entryName)) {
                // entry.getData()将返回Entry相关联的数据作为一个Buffer对象
                const plistBuffer = entry.getData();
                // 确保Buffer不是空的
                if (plistBuffer && plistBuffer.length) {
                    // plist库可以直接解析来自Buffer的二进制或XML plist文件
                    plistData = plist.parse(plistBuffer.toString("utf8"));
                }
            }
        });

        // 如果我们成功解析了plist数据，继续你的数据处理
        if (plistData) {
            // Log the plistData to check content
            console.log(plistData);

            // Continue with more processing...
            // Extract the values you need from plistData
            // ...
        } else {
            // 如果plistData是null，意味着没有在zip中找到Info.plist或者解析失败
            console.error("Info.plist file not found or could not be parsed.");
        }
    },
    // 发包模块  安卓apk-debug包 通过包名 设置type
    setTypeFromPackageName(packageName) {
        console.log(packageName,'packageNamepackageNamepackageNamepackageName')
        if (packageName == "com.ai.chat.bot.aichat") {
            return "chat1";
        } else if (packageName == "com.ai.chat.bot.aichat.lite") {
            return "chat2";
        } else if (packageName == "ai.chat.bot.gpt.mobile.android") {
            return "chat5";
        } else if (packageName == "wamr.recover.backup.undelete.chats.messages") {
            return "wamr";
        } else if (packageName == "com.tree.whatsweb") {
            return "wamr2";
        } else if (
            packageName == "whatsapp.whatsweb.whatscan.dualchat.clone.scanner"
        ) {
            return "wamr3";
        } else if (packageName == "pdf.viewer.editor.office.document.reader") {
            return "pdf";
        } else if (
            packageName == "applock.calculator.lock.hide.photo.private.vault"
        ) {
            return "calculator";
        } else if (
            packageName == "stepcounter.pedometer.steptracker.calorieburner.stepz"
        ) {
            return "stepCounter";
        } else if (
            packageName == "instasave.reels.video.story.ig.instagram.download"
        ) {
            return "android-ins1";
        } else if (packageName == "ins.freevideodownload.pro") {
            return "android-ins";
        } else if (packageName == "video.downloader.insta.videodownloader.ig") {
            return "android-ins3";
        } else if (packageName == "download.video.downloader.videodownloader.mp4") {
            return "android-all";
        } else if (packageName == "DeviceScanDemo") {
            return "remoteTV";
        } else if (packageName == "TypeAI") {
            return "typeAI";
        } else if (packageName == "TT Reposter") {
            return "ios-tt";
        } else if (packageName == "Repost Video") {
            return "ios-ins";
        } else if (packageName == "HeartRate") {
            return "HeartRate";
        } else if (packageName == "seamobitechRemote") {
            return "seamobitechRemote";
        } else if (packageName == "download.video.downloader.videodownloader.instagram") {
            return "android-all2";
        } else if (packageName == "UniversalTVRemoteControl") {
            return "universalControl";
        } else if (packageName == "whatAppT") {
            return "iosWa";
        } else if (packageName == "roku.remote.control.tv.remotecontrol") {
            return "android-roku2";
        }
        else if (packageName == "roku.remote.control.tv.remoteforroku") {
            return "android-roku3";
        }
        else if (packageName == "scan.qr.code.barcode.scanner") {
            return "android-qr";
        }
        else if (packageName == "QRCodeReader") {
            return "iosQR";
        }
        else if (packageName == "BeautyAI") {
            return "iosBeauty";
        }
        else if (packageName == "HeartPulse") {
            return "iosHeartPulse";
        }
        else if (packageName == "TDGeneratedCode") {
            return "iosQR2";
        }
        else if (packageName == "TV Remote Control") {
            return "universalRemote2";
        }
        else if (packageName == "AINoteTaker") {
            return "AINote";
        }
        else if (packageName == "TranslationAI") {
            return "iosTransir";
        }
        else if (packageName == "RecipeAI") {
            return "iosRecipeAI";
        }
        else if (packageName == "food.scanner.calorie.counter.cal.ai" || packageName == "food.calorie.tracker.counter.cal.ai.debug") {
            return "android-Calorie";
        }
        else if (packageName == "print.smart.printer.pdf.docs.scanner" || packageName == "print.smart.printer.pdf.docs.scanner.debug") {
            return "android-Print";
        }
        else if (packageName == "ins") {
            return "iosIns";
        }
        else if (packageName == "WithYou") {
            return "iosWithYou";
        }
        else if (packageName == "Museo") {
            return "iosMuseo";
        }
        else if (packageName == "kokoTranslation") {
            return "iosKOKO";
        }
        return "packageName";
    },
    //根据ip  return域名
    getDomainByIP(host) {
        if (host == "45.76.212.42") {
            return "https://insdoss.freeapptools.com";
        } else if (host == "170.187.230.149") {
            return "https://fd.freevideodownload.pro";
        } else if (host == "172.104.35.128") {
            return "https://pdf.seamobitech.com";
        } else if (host == "192.46.226.198") {
            return "https://tp.seamobitech.com";
        }
    },
    //根据类型 return 下载网页
    getDownloadPageByType(type) {

        if (type == "android-ins") {
            return "https://fd.freevideodownload.pro/saveAndroidFile-node/ins.html";
        } else if (type == "typeAI") {
            return "https://insdoss.freeapptools.com/saveIosTypeAi-node/TypeAI.html";
        } else if (type == "android-all") {
            return "https://fd.freevideodownload.pro/saveAndroidAllFile-node/all.html";
        } else if (type == "remoteTV") {
            return "https://wamr.seamobitech.com/saveRemoteTV-node/remoteTV.html";
        } else if (type == "seamobitechRemote") {
            return "https://insdoss.freeapptools.com/saveIosRokuRemoteNode/seamobitechRemote.html";
        }
        else if (type == "android-all2") {
            return "https://fd.freevideodownload.pro/saveAndroidAll2File-node/all2.html";
        } else if (type == "universalControl") {
            return "https://pdf.seamobitech.com/saveUniversalControlNode/universalControl.html";
        } else if (type == "iosWa") {
            return "https://insdoss.freeapptools.com/saveIosWaNode/iosWa.html";
        }
        else if (type == "android-roku2") {
            return "https://fd.freevideodownload.pro/saveAndroidRoku2/androidRoku2.html";
        }
        else if (type == "android-roku3") {
            return "https://fd.freevideodownload.pro/saveAndroidRoku3/androidRoku3.html";
        }
        else if (type == "android-Calorie") {
            return "https://fd.freevideodownload.pro/saveAndroidCalorie/androidCalorie.html";
        }
        else if (type == "android-Print") {
            return "https://fd.freevideodownload.pro/saveAndroidPrint/androidPrint.html";
        }
        else if (type == "android-qr") {
            return "https://fd.freevideodownload.pro/saveAndroidQr/androidQr.html";
        }
        else if (type == "iosQR") {
            return "https://insdoss.freeapptools.com/saveIosQRNode/iosQR.html";
        }
        else if (type == "iosQR2") {
            return "https://insdoss.freeapptools.com/saveIosQRNode2/iosQR2.html";
        }
        else if (type == "iosBeauty") {
            return "https://insdoss.freeapptools.com/saveIosBeautyNode/iosBeauty.html";
        }
        else if (type == "iosHeartPulse") {
            return "https://insdoss.freeapptools.com/saveIosHeartPulseNode/iosHeartPulse.html";
        }
        else if (type == "universalRemote2") {
            return "https://insdoss.freeapptools.com/saveIosUniversalRemote2Node/universalRemote2.html";
        }
        else if (type == "AINote") {
            return "https://insdoss.freeapptools.com/saveIosAINoteNode/AINote.html";
        }
        else if (type == "iosTransir") {
            return "https://insdoss.freeapptools.com/saveIosTransir/iosTransir.html";
        }
        else if (type == "iosRecipeAI") {
            return "https://insdoss.freeapptools.com/saveIosRecipeAINode/RecipeAI.html";
        }
        else if (type == "iosIns") {
            return "https://insdoss.freeapptools.com/saveIosInsNode/iosIns.html";
        }
        else if (type == "iosWithYou") {
            return "https://insdoss.freeapptools.com/saveIosWithYouNode/iosWithYou.html";
        }
        else if (type == "iosMuseo") {
            return "https://insdoss.freeapptools.com/saveIosMuseoNode/iosMuseo.html";
        }
        else if (type == "iosKOKO") {
            return "https://insdoss.freeapptools.com/saveIosKOKO/iosKOKO.html";
        }
    },
    //根据类型 return 群id
    getGroupIdByType(type) {
        if (type == "android-ins") {
            return "oc_be46490aab46c35d7b001b85d172cdd6";
        } else if (type == "typeAI") {
            return "oc_780c3845deb204ed5d6cffa5922012b4";
        } else if (type == "android-all") {
            return "oc_be46490aab46c35d7b001b85d172cdd6";
        } else if (type == "remoteTV" || type == "universalControl") {
            return "oc_9c861e8af573f2192d243a23cb67e412";
        } else if (type == "HeartRate") {
            return "oc_300d536417e7a4d6a47c27bc43b00bb0";
        } else if (type == "seamobitechRemote") {
            return "oc_9c861e8af573f2192d243a23cb67e412";
        } else if (type == "pdf") {
            return "oc_300d536417e7a4d6a47c27bc43b00bb0";
        }
        else if (type == "android-all2") {
            return "oc_be46490aab46c35d7b001b85d172cdd6";
        }
        else if (type == "iosWa") {
            return "oc_43a0f6d39cffe73d48ac5dd67ac0fba6";
        }
        else if (type == "android-roku2") {
            return "oc_bcc0bf09efae4391e59fb1223c2523b6";
        }
        else if (type == "android-roku3") {
            return "oc_bcc0bf09efae4391e59fb1223c2523b6";
        }
        else if (type == "android-Calorie") {
            return "oc_aca3bd49c00e28ced928c4a1bf3495e2";
        }
        else if (type == "android-Print") {
            return "oc_28325b812873bdb4d04f5f1d1a5ac274";
        }
        else if (type == "android-qr") {
            return "oc_4b39ebb99d84659f1e6f59be449cc7c2";
        }
        else if (type == "iosQR") {
            return "oc_4b39ebb99d84659f1e6f59be449cc7c2";
        }
        else if (type == "iosQR2") {
            return "oc_4b39ebb99d84659f1e6f59be449cc7c2";
        }
        else if (type == "iosBeauty") {
            return "oc_745941b33216de0b0ec0f778fc861e17";
        }
        else if (type == "iosHeartPulse") {
            return "oc_0f7e0a424d63200227dc2b032553d64a";
        }
        else if (type == "universalRemote2") {
            return "oc_2021d6a78d6f1ee9b41d2dc7657644df";
            // return "oc_300d536417e7a4d6a47c27bc43b00bb0";
        }
        else if (type == "AINote") {
            return "oc_ab593b0c73484fa3b404b14cf7400d80";
        }
        else if (type == "iosTransir") {
            return "oc_4b39ebb99d84659f1e6f59be449cc7c2";
            // return "oc_300d536417e7a4d6a47c27bc43b00bb0";
        }
        else if (type == "iosRecipeAI") {
            return "oc_a2b6278259ec5f869a2978fceab43e41";
        }
        else if (type == "iosIns") {
            return "oc_732cf2c2cacd46537a187074eb658837";
        }
        else if (type == "iosWithYou") {
            return "oc_5c933de2551f56cdd0ed86b32b078950";
        }
        else if (type == "iosKOKO") {
            return "oc_4b39ebb99d84659f1e6f59be449cc7c2";
            // return "oc_300d536417e7a4d6a47c27bc43b00bb0";
        }
        else if (type == "packageName") {
            return "oc_300d536417e7a4d6a47c27bc43b00bb0";
        }

        
    },
    //根据type类型 经不同服务器 发布到gp生产环境
    deployGp(type, grayscale, isPro) {
        return new Promise((resolve, reject) => {
            let remoteConfig = {
                host: "",
                port: "22",
                username: "root",
                password: "",
            };
            let command = "";
            if (type == "pdf") {
                remoteConfig.host = "172.104.35.128";
                remoteConfig.port = "22";
                remoteConfig.password = "zhijianNo.1-128";
                command = isPro
                    ? "sh /zj-manager/fastlane/fastlane/pro.sh" + " " + grayscale
                    : "sh /zj-manager/fastlane/fastlane/start.sh";
            } else if (type == "android-ins") {
                remoteConfig.host = "170.187.230.149";
                remoteConfig.port = "22";
                remoteConfig.password = "zhijianNo.1-149";
                command = isPro
                    ? "sh /zj-manager-production/fastlane/fastlane/pro.sh" +
                    " " +
                    grayscale
                    : "sh /zj-manager-production/fastlane/fastlane/start.sh";
            } else if (type == "android-all") {
                console.log(
                    "进了android-allandroid-allandroid-allandroid-allandroid-all"
                );
                remoteConfig.host = "170.187.230.149";
                remoteConfig.port = "22";
                remoteConfig.password = "zhijianNo.1-149";
                command = isPro
                    ? "sh /zj-manager-production/fastlane-all/fastlane-all/pro.sh" +
                    " " +
                    grayscale
                    : "sh /zj-manager-production/fastlane-all/fastlane-all/start.sh";
            }
            console.log(command, "command");

            conn
                .on("ready", () => {
                    console.log("Client :: ready");
                    conn.exec(command, (err, stream) => {
                        if (err) {
                            reject("执行命令时发生错误:" + err);
                            return conn.end();
                        }

                        let result = "";

                        stream
                            .on("close", (code, signal) => {
                                console.log(
                                    "Stream :: close :: code:",
                                    code,
                                    ", signal:",
                                    signal
                                );
                                resolve(result);
                                conn.end(); // 当stream关闭时结束SSH连接
                            })
                            .on("data", (data) => {
                                // 这里将捕获正常的命令输出（stdout）
                                result += data.toString(); // 收集数据
                                console.log("STDOUT:", data.toString());
                            })
                            .stderr.on("data", (data) => {
                                // 这里捕获任何错误输出（stderr）
                                reject("STDERR:" + data.toString());
                            });
                    });
                })
                .on("error", (err) => {
                    reject("SSH连接错误:" + err);
                })
                .connect(remoteConfig);
        });
    },

    //根据权限字段 处理上传列表的 查询
    filterUploadListByRoleKey(roleKeys) {
        const resultArray = [];

        // 循环判断数组中的元素
        roleKeys.forEach((roleKey) => {
            if (roleKey == "app:appPackageUpload:typeAI") {
                resultArray.push("typeAi");
            }
            if (roleKey == "app:appPackageUpload:androidDownloaderAll") {
                resultArray.push("android-all");
            }
            if (roleKey == "app:appPackageUpload:androidIns") {
                resultArray.push("android-ins");
            }
            if (roleKey == "app:appPackageUpload:remoteTV") {
                resultArray.push("remoteTV");
            }
            if (roleKey == "app:appPackageUpload:roku") {
                resultArray.push("seamobitechRemote");
            }
            if (roleKey == "app:appPackageUpload:androidDownloaderAll2") {
                resultArray.push("android-all2");
            }
            if (roleKey == "app:appPackageUpload:universalControl") {
                resultArray.push("universalControl");
            }
            if (roleKey == "app:appPackageUpload:iosWa") {
                resultArray.push("iosWa");
            }
            if (roleKey == "app:appPackageUpload:androidLG") {
                resultArray.push("tv.remote.control.lg.tvremote");
            }
            if (roleKey == "app:appPackageUpload:androidRoku") {
                resultArray.push("tv.roku.remote.control.tvremote");
            }
            if (roleKey == "app:appPackageUpload:androidSamsung") {
                resultArray.push("samsung.remote.control.samsungtv");
            }
            if (roleKey == "app:appPackageUpload:androidFiretv") {
                resultArray.push("tv.remote.firetv.firestick");
            }


            if (roleKey == "app:appPackageUpload:iosQR") {
                resultArray.push("iosQR");
            }
            if (roleKey == "app:appPackageUpload:iosQR2") {
                resultArray.push("iosQR2");
            }
            if (roleKey == "app:appPackageUpload:roku2") {
                resultArray.push("android-roku2");
            }
            if (roleKey == "app:appPackageUpload:roku3") {
                resultArray.push("android-roku3");
            }
            if (roleKey == "app:appPackageUpload:Calorie") {
                resultArray.push("android-Calorie");
            }
            if (roleKey == "app:appPackageUpload:Print") {
                resultArray.push("android-Print");
            }
            if (roleKey == "app:appPackageUpload:androidQr") {
                resultArray.push("android-qr");
            }
            if (roleKey == "app:appPackageUpload:iosBeauty") {
                resultArray.push("iosBeauty");
            }
            if (roleKey == "app:appPackageUpload:iosHeartPulse") {
                resultArray.push("iosHeartPulse");
            }
            if (roleKey == "app:appPackageUpload:universalRemote2") {
                resultArray.push("universalRemote2");
            }
            if (roleKey == "app:appPackageUpload:AINote") {
                resultArray.push("AINote");
            }
            if (roleKey == "app:appPackageUpload:iosRecipeAI") {
                resultArray.push("iosRecipeAI");
            }
            if (roleKey == "app:appPackageUpload:iosTransir") {
                resultArray.push("iosTransir");
            }
        });
        return resultArray; // 返回结果数组
    },
    //根据权限字段 处理反馈列表的 查询
    filterFeedbackListByRoleKey(roleKeys) {
        const resultArray = [];

        // 循环判断数组中的元素
        roleKeys.forEach((roleKey) => {
            if (roleKey == "app:appPackageUpload:typeAI") {
                resultArray.push("com.seamobitech.aboard");
            }
            if (roleKey == "app:appPackageUpload:androidDownloaderAll") {
                resultArray.push("download.video.downloader.videodownloader.mp4");
            }
            if (roleKey == "app:appPackageUpload:androidDownloaderAll2") {
                resultArray.push("download.video.downloader.videodownloader.instagram");
            }
            if (roleKey == "app:appPackageUpload:androidIns") {
                resultArray.push("ins.freevideodownload.pro");
            }
            if (roleKey == "app:appPackageUpload:remoteTV") {
                resultArray.push("com.ZhiJian.LGTVRemote");
            }
            if (roleKey == "app:appPackageUpload:roku") {
                resultArray.push("com.seamobitech.roku");
                resultArray.push("com.davinci.roku");
            }

            if (roleKey == "app:appPackageUpload:androidLG") {
                resultArray.push("tv.remote.control.lg.tvremote");
            }
            if (roleKey == "app:appPackageUpload:androidRoku") {
                resultArray.push("tv.roku.remote.control.tvremote");
            }
            if (roleKey == "app:appPackageUpload:androidSamsung") {
                resultArray.push("samsung.remote.control.samsungtv");
            }
            if (roleKey == "app:appPackageUpload:androidFiretv") {
                resultArray.push("tv.remote.firetv.firestick");
            }
            if (roleKey == "app:appPackageUpload:universalControl") {
                resultArray.push("com.zhijian.LGTVRemoteTest.224");
                resultArray.push("com.seamobitech.UniversalTVRemoteControl");
            }
            if (roleKey == "app:brand") {
                resultArray.push("com.zhijian.LGTVRemoteTest");
                resultArray.push("com.seamobitech.UniversalTVRemoteControl");
            }
            if (roleKey == "app:appPackageUpload:iosWa") {
                resultArray.push("com.tcpluginunit.testApp");
                resultArray.push("com.seamobitech.whatsscanwebclone");
            }
            if (roleKey == "app:appPackageUpload:iosQR") {
                resultArray.push("qrcode.QRCodeReader.www");
                resultArray.push("com.seamobitech.QRCodeReadAndGenerate");
            }
            if (roleKey == "app:appPackageUpload:iosQR2") {
                resultArray.push("qrcode.QRCodeMaker");
                resultArray.push("com.seamobitech.QRCodeCreateAndRead");
            }
            if (roleKey == "app:appPackageUpload:roku2") {
                resultArray.push("roku.remote.control.tv.remotecontrol");
            }
            if (roleKey == "app:appPackageUpload:roku3") {
                resultArray.push("roku.remote.control.tv.remoteforroku");
            }
            if (roleKey == "app:appPackageUpload:Calorie") {
                resultArray.push("food.scanner.calorie.counter.cal.ai");
                resultArray.push("food.scanner.calorie.counter.cal.ai.debug");
            }
            if (roleKey == "app:appPackageUpload:Print") {
                resultArray.push("print.smart.printer.pdf.docs.scanner");
                resultArray.push("print.smart.printer.pdf.docs.scanner.debug");
            }
            if (roleKey == "app:appPackageUpload:androidQr") {
                resultArray.push("scan.qr.code.barcode.scanner");
            }
            if (roleKey == "app:appPackageUpload:iosBeauty") {
                resultArray.push("com.seamobitech.BeautyAI");
                resultArray.push("com.tcdemotc.testApp");
            }
            if (roleKey == "app:appPackageUpload:iosHeartPulse") {
                resultArray.push("com.seamobitech.HeartPulse");
                resultArray.push("com.zhijian.LGTVRemoteTest.HeartPulse");
            }
            if (roleKey == "app:appPackageUpload:universalRemote2") {
                resultArray.push("com.zhijian.TV-Remote-Control");
                resultArray.push("com.zhijian.remoteControl");
            }
            if (roleKey == "app:appPackageUpload:AINote") {
                resultArray.push("com.zhijian.AINoteTaker");
                resultArray.push("com.finger.AINoteTaker");
            }
            if (roleKey == "app:appPackageUpload:iosRecipeAI") {
                resultArray.push("com.tcrecipeai.testApp");
                resultArray.push("com.finger.AIRecipes");
            }
            if (roleKey == "app:appPackageUpload:iosTransir") {
                resultArray.push("com.trans.translationAiAndSubtitle");
                resultArray.push("com.TranslationAISubTitle");
            }
        });
        return resultArray; // 返回结果数组
    },

    //根据权限字段 处理app版本管理列表的 查询
    filterAppVersionListByRoleKey(roleKeys) {
        const resultArray = [];

        // 循环判断数组中的元素
        roleKeys.forEach((roleKey) => {
            if (roleKey == "app:appVersion:iosWA") {
                resultArray.push("com.seamobitech.whatsscanwebclone");
            }
            if (roleKey == "app:appVersion:iosBeauty") {
                resultArray.push("com.seamobitech.BeautyAI");
            }
            if (roleKey == "app:appVersion:iosQR1") {
                resultArray.push("com.seamobitech.QRCodeReadAndGenerate");
            }
            if (roleKey == "app:appVersion:iosQR2") {
                resultArray.push("com.seamobitech.QRCodeCreateAndRead");
            }
            if (roleKey == "app:appPackageUpload:AINote") {
                resultArray.push("com.finger.AINoteTaker");
            }
            if (roleKey == "app:appPackageUpload:iosRecipeAI") {
                resultArray.push("com.finger.AIRecipes");
            }
            if (roleKey == "app:appPackageUpload:iosTransir") {
                resultArray.push("com.trans.translationAiAndSubtitle");
            }
            if (roleKey == "app:appPackageUpload:iosTransir") {
                resultArray.push("com.TranslationAISubTitle");
            }
        });
        return resultArray; // 返回结果数组
    },

    //根据包名查询名下所有的5星模板
    async getFiveStarTemplatesByPackageName(pk) {
        return new Promise((resolve, reject) => {
            let sql = `SELECT * FROM js_app_comment_template WHERE package_name = ? AND type_id IS NULL`;
            pool.query(sql, [pk], (err, result) => {
                if (err) return;
                resolve(result);
            });
        });
    },
    //根据包名和语种筛选除一条评论数据
    async getCommentByPackageAndLanguage(pk, lang) {
        return new Promise((resolve, reject) => {
            let sql = ` SELECT * FROM js_app_comment 
      WHERE package_name = ? 
      AND reviewer_language = ? 
      AND is_reply = 0 
      AND star_rating = 5 
      ORDER BY RAND() 
      LIMIT 1;`;
            pool.query(sql, [pk, lang], (err, result) => {
                if (err) return;
                resolve(result);
            });
        });
    },
    //回复
    async reviewsReply(
        package_name,
        reply_content,
        review_id,
        template_content_id
    ) {
        // let { name } = await this.getUserInfo(req, res);

        const androidPublisher = await androidPublisherConn(package_name);
        // 创建评论回复
        const reply = {
            replyText: reply_content,
        };
        const response = await androidPublisher.reviews.reply({
            packageName: package_name,
            reviewId: review_id,
            requestBody: reply,
        });
        const replyRes = JSON.stringify(response.data);
        if (replyRes.includes("replyText")) {
            //成功  存入数据库
            // 通过review_id 查
            let comment = {};
            comment.reply_content = reply_content;
            comment.reply_id = uuidv4().replace(/-/g, "");
            comment.reply_date = this.formatDate(new Date());
            comment.update_by = 'admin';
            comment.update_date = this.formatDate(new Date());
            comment.is_reply = 1;
            comment.template_content_id = template_content_id;
            // 更新js_app_comment表中匹配review_id的记录
            let sqlUpdate = `UPDATE js_app_comment SET reply_content = ?, reply_id = ?, reply_date = ?, update_by = ?, update_date = ?, is_reply = ?, template_content_id = ? WHERE review_id = ?`;
            let valuesUpdate = [
                comment.reply_content,
                comment.reply_id,
                comment.reply_date,
                comment.update_by,
                comment.update_date,
                comment.is_reply,
                comment.template_content_id,
                review_id,
            ];
            await pool.query(sqlUpdate, valuesUpdate, (updateErr, updateResult) => {
                console.log("自动回复到gp,成功！存入数据库成功！");
            });
            // res.json({ code: 200, message: "Reply successful" });
        } else {
            console.log("自动回复到gp,失败");
        }
    },

    getApkPathBasedOnPackageName(type) {
        if (type == 'android-all') {
            return `/saveAndroidAllFile-node/app-release.aab`
        }
        if (type == 'android-all2') {
            return `/saveAndroidAll2File-node/app-release.aab`
        }
        if (type == 'android-ins') {
            return `/saveAndroidFile-node/app-release.aab`
        }
        if (type == 'android-roku2') {
            return `/saveAndroidRoku2/app-release.aab`
        }
        if (type == 'android-roku3') {
            return `/saveAndroidRoku3/app-release.aab`
        }
        if (type == 'android-Calorie') {
            return `/saveAndroidCalorie/app-release.aab`
        }
        if (type == 'android-Print') {
            return `/saveAndroidPrint/app-release.aab`
        }
        if (type == 'android-qr') {
            return `/saveAndroidQr/app-release.aab`
        }

    },
    //根据type 决定走哪个服务器的接口
    getServerEndpointByType(type, fileName) {
        if (type == "pdf") {
            return `https://pdf.seamobitech.com/node/uploadPackage/changeUpload?type=${type
                }&name=${fileName}`;
        } else if (type == "typeAI") {
            return `https://insdoss.freeapptools.com/node/uploadPackage/changeUpload?type=${type
                }&name=${fileName}`;
        } else if (type == "remoteTV") {
            return `https://pdf.seamobitech.com/node/uploadPackage/changeUpload?type=${type
                }&name=${fileName}`;
        } else if (type == "seamobitechRemote") {
            return `https://insdoss.freeapptools.com/node/uploadPackage/changeUpload?type=${type
                }&name=${fileName}`;
        } else if (
            type == "android-all" ||
            type == "android-ins" || type == "android-all2"
        ) {
            return `https://fd.freevideodownload.pro/node/uploadPackage/changeUpload?type=${type
                }&name=${fileName}`;
        } else if (type == "universalControl") {
            return `https://pdf.seamobitech.com/node/uploadPackage/changeUpload?type=${type
                }&name=${fileName}`;
        } else if (type == "iosWa") {
            return `https://insdoss.freeapptools.com/node/uploadPackage/changeUpload?type=${type
                }&name=${fileName}`;
        } else if (type == "android-roku2") {
            return `https://fd.freevideodownload.pro/node/uploadPackage/changeUpload?type=${type
                }&name=${fileName}`;
        }
        else if (type == "android-roku3") {
            return `https://fd.freevideodownload.pro/node/uploadPackage/changeUpload?type=${type
                }&name=${fileName}`;
        }
        else if (type == "android-Calorie") {
            return `https://fd.freevideodownload.pro/node/uploadPackage/changeUpload?type=${type
                }&name=${fileName}`;
        }
        else if (type == "android-Print") {
            return `https://fd.freevideodownload.pro/node/uploadPackage/changeUpload?type=${type
                }&name=${fileName}`;
        }
        else if (type == "android-qr") {
            return `https://fd.freevideodownload.pro/node/uploadPackage/changeUpload?type=${type
                }&name=${fileName}`;
        }
        else if (type == "iosQR") {
            return `https://insdoss.freeapptools.com/node/uploadPackage/changeUpload?type=${type
                }&name=${fileName}`;
        }
        else if (type == "iosQR2") {
            return `https://insdoss.freeapptools.com/node/uploadPackage/changeUpload?type=${type
                }&name=${fileName}`;
        }
        else if (type == "iosBeauty") {
            return `https://insdoss.freeapptools.com/node/uploadPackage/changeUpload?type=${type
                }&name=${fileName}`;
        }
        else if (type == "iosHeartPulse") {
            return `https://insdoss.freeapptools.com/node/uploadPackage/changeUpload?type=${type
                }&name=${fileName}`;
        }
        else if (type == "universalRemote2") {
            return `https://insdoss.freeapptools.com/node/uploadPackage/changeUpload?type=${type
                }&name=${fileName}`;
        }
        else if (type == "AINote") {
            return `https://insdoss.freeapptools.com/node/uploadPackage/changeUpload?type=${type
                }&name=${fileName}`;
        }
        else if (type == "iosTransir") {
            return `http://45.76.212.42:5000/node/uploadPackage/changeUpload?type=${type
                }&name=${fileName}`;
        }
        else if (type == "iosRecipeAI") {
            return `https://insdoss.freeapptools.com/node/uploadPackage/changeUpload?type=${type
                }&name=${fileName}`;
        }
        else if (type == "iosIns") {
            return `https://insdoss.freeapptools.com/node/uploadPackage/changeUpload?type=${type
                }&name=${fileName}`;
        }
        else if (type == "iosWithYou") {
            return `http://45.76.212.42:5000/node/uploadPackage/changeUpload?type=${type
                }&name=${fileName}`;
        }
        else if (type == "iosMuseo") {
            return `http://45.76.212.42:5000/node/uploadPackage/changeUpload?type=${type
                }&name=${fileName}`;
        }
        else if (type == "iosKOKO") {
            return `http://45.76.212.42:5000/node/uploadPackage/changeUpload?type=${type
                }&name=${fileName}`;
        }
    },
};
